find_package(PkgConfig REQUIRED)
find_package(libmc4lua)
find_package(libsoc_adapter)
pkg_search_module(DBUS REQUIRED dbus-1)

set(SPDM_LIB spdm_core)

include_directories(include ${LIBSPDM_INCLUDE_DIRS})

file(GLOB SOURCES
    "common/*.cpp"
    "protocol/*.cpp"
    "transfer/*.cpp"
    "certificate/*.cpp"
    "measurement/*.cpp"
    "responder/*.cpp"
    "service/*.cpp"
)

add_library(${SPDM_LIB} SHARED ${SOURCES})

target_include_directories(${SPDM_LIB}
    PUBLIC ${LIBSPDM_INCLUDE_DIRS}
    PUBLIC ${CONAN_INCLUDE_DIRS}
    PUBLIC ${LUACLIB_SRC_DIR}
    PUBLIC libsoc_adapter
)

link_directories(${LIBSPDM_LIBRARY_DIRS})

target_link_libraries(${SPDM_LIB}
    PUBLIC ${LIBSPDM_LIBRARIES}
    PUBLIC ${CONAN_LIBS}
    PUBLIC ${CONAN_LIBS_HUAWEI_SECURE_C}
    PUBLIC libsoc_adapter::libsoc_adapter
)

target_link_directories(${SPDM_LIB} PUBLIC
    ${LIBSPDM_LIBRARY_DIRS}
)

list(PREPEND CMAKE_LIBRARY_PATH ${LIBSPDM_LIBRARY_DIRS})

set_target_properties(${SPDM_LIB} PROPERTIES PREFIX "")
install(TARGETS ${SPDM_LIB} DESTINATION ${LUACLIB_INSTALL_DIR} PERMISSIONS OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE)